// import Cookies from 'js-cookie'
import XEUtils from "xe-utils";

const TokenKey = "Admin-Token"
const RefreshTokenKey = "Admin-Refresh-Token"
const Menu = "Admin-Menu"
const UserMsg = "Admin-Msg"

// export function getToken() {
//   return Cookies.get(TokenKey);
// }

// export function setToken(token) {
//   return Cookies.set(TokenKey, token);
// }

// export function removeToken() {
//   return Cookies.remove(TokenKey)
// }
export function clearAll() {
  localStorage.clear();
  sessionStorage.clear();
}

export function getToken() {
  return localStorage.getItem(TokenKey);
}

export function setToken(token) {
  localStorage.setItem(TokenKey, token);
}

export function removeToken() {
  localStorage.removeItem(TokenKey)
}

export function getRefreshToken() {
  return localStorage.getItem(RefreshTokenKey);
}

export function setRefreshToken(refreshToken) {
  localStorage.setItem(RefreshTokenKey, refreshToken);
}

export function removeRefreshToken() {
  localStorage.removeItem(RefreshTokenKey)
}

export function getMenu() {
  const MenuData = localStorage.getItem(Menu);
  return MenuData ? XEUtils.toStringJSON(MenuData) : [];
}

export function setMenu(menuList) {
  localStorage.setItem(Menu, XEUtils.toJSONString(menuList));
}

export function removeMenu() {
  localStorage.removeItem(Menu)
}

export function getUserMsg() {
  const UserMsgData = localStorage.getItem(UserMsg);
  return UserMsgData ? XEUtils.toStringJSON(UserMsgData) : {};
}

export function setUserMsg(UserMsgList) {
  localStorage.setItem(UserMsg, XEUtils.toJSONString(UserMsgList));
}

export function removeUserMsg() {
  localStorage.removeItem(UserMsg)
}
